﻿using BEPUphysics;
using BEPUphysics.Entities;

namespace Asplode.Physics
{

    public class PhysicsEventHandler
    {
        private Space Space;

        public PhysicsEventHandler(Space space)
        {
            Space = space;
        }

        public void subscribe(EventDispatcher EventDispatcher)
        {
            EventDispatcher.BoxSpawn += new EventDispatcher.BoxSpawnHandler(EventDispatcher_BoxSpawn);
            EventDispatcher.HumanSpawn += new EventDispatcher.HumanSpawnHandler(EventDispatcher_HumanSpawn);
            EventDispatcher.RemoveEntity += new EventDispatcher.RemoveEntityHandler(EventDispatcher_RemoveEntity);
            EventDispatcher.ZombieSpawn += new EventDispatcher.ZombieSpawnHandler(EventDispatcher_ZombieSpawn);
            
        }        

        void EventDispatcher_BoxSpawn(Box box)
        {
            Space.add(box);
        }

        void EventDispatcher_HumanSpawn(Entity entity)
        {
            Space.add(entity);
        }

        void EventDispatcher_RemoveEntity(Entity entity)
        {
            Space.remove(entity);
        }

        void EventDispatcher_ZombieSpawn(Entity entity)
        {
            Space.add(entity);
        }
    }
}
